import {date
} from "quasar";

export function formatProjectData(data) {
  let projectList = []
  data.forEach((item) => {
      let curtime = new Date().getTime();
      let stime = parseInt(item.stime);
      let etime = parseInt(item.etime);
      if (item.rank == 0) {
          item.color = "pink-6";
      } else if (item.rank == 1) {
          item.color = "teal-6";
      } else if (item.rank == 2) {
          item.color = "yellow-8";
      } else if (item.rank == 3) {
          item.color = "blue-6";
      }
      if (stime > curtime) {
          item.progress = 0;
      } else if (etime < curtime) {
          item.progress = 100;
      } else {
          item.progress = parseFloat(
              (((curtime - stime) / (etime - stime)) * 100).toFixed(1)
          );
      }
      item.stime = date.formatDate(stime, "YYYY/MM/DD");
      item.etime = date.formatDate(etime, "YYYY/MM/DD");

      projectList.push(item);
  });
  return projectList
}
